package com.bjfu.gmms.servlet;

import com.bjfu.gmms.MyBatisUtil;
import com.bjfu.gmms.mapper.AdminSecretaryMapper;
import com.bjfu.gmms.mapper.PhaseMapper;
import com.bjfu.gmms.model.Pairing;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/viewResultServlet")
public class LeaderViewResultServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try(SqlSession sqlSession = MyBatisUtil.getSqlSession("development")){

                AdminSecretaryMapper mapper = sqlSession.getMapper(AdminSecretaryMapper.class);
                // 调用 Mapper 中的方法查询数据
                List<Pairing> pairingList = mapper.getCollegeMentorStudentPairing("004");
                request.getSession().setAttribute("pairingList", pairingList);
                request.getRequestDispatcher("allResultsQuery.jsp").forward(request, response);
            }
        }
    }

